package dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;

import saa.model.usuario.Aluno;

public class AlunoDao implements AlunoDaoImpl {
	
	protected EntityManager entityManager;
	
	public EntityManager getEntityManager() {
        return this.entityManager;
    }
	
	@PersistenceContext(unitName = "SAA-EJB")
    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }
	
    //@Transactional
	public List<Aluno> getAlunos() {
    	Query query = getEntityManager().createQuery("SELECT c FROM USUARIO c");
    	List<Aluno> result = (List<Aluno>)query.getResultList(); 
    	return result;
	}

    //@Transactional
	public Aluno getAluno(int alunoId) {
    	return getEntityManager().find(Aluno.class, alunoId);
	}
}
